package homework.day05;

import file.CreateNewFileDemo;

import java.io.*;

/**
 * 改正下面程序的错误
 * <p>
 * 向文件testpw.txt中以UTF-8编码写入一行字符串：
 * 你好!我喜欢java!
 * <p>
 * 单词记一记:
 * print 打印
 *
 * @author Xiloer
 */
public class Test01 {
    public static void main(String[] args) throws IOException {
        String line = "你好!我喜欢java!";
        File file = new File("testpw.txt");
        if(file.exists()){
            System.out.println("文件已存在!");
        }else {
            file.createNewFile();
            System.out.println("文件已创建!");
        }
        FileOutputStream fos = new FileOutputStream("testpw.txt");
        fos.write(line.getBytes("UTF-8"));
        System.out.println("执行完毕!");
    }

}
